﻿Imports Sunisoft.IrisSkin
Imports System.Data.SqlClient
Imports System.IO
Public Class Frm_Main
    Dim skin As SkinEngine

    Private Sub Frm_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KetNoiSQL()

        'loadSkin("skins\Diamond Green.ssk")

    End Sub

  


    Private Sub lsp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lsp.Click
        Frm_LoaiSP.ShowDialog()
    End Sub

    Private Sub sp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sp.Click
        Frm_SanPham.MdiParent = Me
        Frm_SanPham.Show()
    End Sub

    Private Sub dvt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dvt.Click
        Frm_DonViTinh.ShowDialog()
    End Sub

    Private Sub nv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nv.Click
        Frm_NhanVien.ShowDialog()
    End Sub

    Private Sub NCC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NCC.Click
        Frm_NhaCungCap.ShowDialog()
    End Sub

  
    Private Sub PN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PN.Click
        Frm_PhieuNhap.MdiParent = Me
        Frm_PhieuNhap.Show()


    End Sub
#Region "thay doi skin"
    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ' Add an initialization after the InitializeComponent() call.
        skin = New SkinEngine
        skin.SerialNumber = "Y89DFfB3yDTWITfDt5ZwPIrz6rhiM3ayC895MX14kiJ+Bn5fwDsogQ=="
        skin.BuiltIn = True
        skin.SkinAllForm = True
        skin.Active = False
        loadSkinsMenu()
        loadSkin("Vista.ssk")

    End Sub
    Private Sub menu_click(ByVal send As Object, ByVal ea As EventArgs)
        Dim menu As ToolStripMenuItem = CType(send, ToolStripMenuItem)
        ' For Each tsm As ToolStripMenuItem In ChangeSkin.DropDownItems
        ' tsm.Checked = False
        'Next tsm
        'If menu Is ChangeSkin.DropDownItems(0) Then
        skin.SkinAllForm = False
        skin.Active = False
        menu.Checked = True
        Return
        'End If
        ' Dim skinlocal As String = "skins\" & menu.Text & ".ssk"
        'loadSkin(skinlocal)
        menu.Checked = True
    End Sub
    'Hàm load skin menu
    Private Sub loadSkinsMenu()
        Try
            Dim files() As String = Directory.GetFiles("skins", "*.ssk", SearchOption.TopDirectoryOnly)
            Dim skinmenu(files.Length - 1) As ToolStripMenuItem
            Dim defaultSkin As New ToolStripMenuItem()
            'defaultSkin.Text = "Longhorn"

            defaultSkin.Checked = True
            AddHandler defaultSkin.Click, AddressOf menu_click
            'ChangeSkin.DropDownItems.Add(defaultSkin)
            For i As Integer = 0 To files.Length - 1
                Dim temp() As String = files(i).Split("\")
                temp = temp(temp.Length - 1).Split(".")
                skinmenu(i) = New ToolStripMenuItem()
                skinmenu(i).Text = temp(0)
                AddHandler skinmenu(i).Click, AddressOf menu_click
                ' ChangeSkin.DropDownItems.Add(skinmenu(i))
            Next i
        Catch ex As Exception
            MessageBox.Show(ex.Message, "L?i", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    Private Sub loadSkin(ByVal skinFile As String)
        Try
            skin.SkinFile = skinFile
            skin.SkinAllForm = True
            skin.Active = True
        Catch
            MessageBox.Show("Lỗi.", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
#End Region

    Private Sub ChangeSkin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DangNhap.Click
        Frm_PhieuNhap.MdiParent = Me
        Frm_PhieuNhap.Show()
    End Sub
    Private Sub HoaDon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HoaDon.Click
        Frm_HoaDon.MdiParent = Me
        Frm_HoaDon.Show()
    End Sub

    Private Sub BCHoaDon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BCHoaDon.Click
        R_HoaDon.MdiParent=Me
        R_HoaDon.Show()
    End Sub
End Class
